<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Message\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 消息表验证数据类
 */
class MessageRequest extends FormRequest
{

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            //消息类型1预警2反馈3系统 验证
            'type' => 'required|in:1,2,3',
            //消息标题 验证
            'title' => 'max:255',
            //消息内容 验证
            'content' => 'required|string',
            //关联ID 验证
            'related_id' => 'integer',
            //接收用户ID数组 验证
            'push_user' => 'array',
            //消息级别1普通2重要3紧急 验证
            'level' => 'required|in:1,2,3',
        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'type' => '消息类型1预警2反馈3系统',
            'title' => '消息标题',
            'content' => '消息内容',
            'related_id' => '关联ID',
            'push_user' => '接收用户ID数组',
            'level' => '消息级别1普通2重要3紧急',
        ];
    }

    public function messages(): array
    {
        return [
            'type.required' => '请选择消息类型',
            'type.in' => '消息类型只能是1、2或3',
            'content.required' => '请输入消息内容',
            'level.required' => '请选择消息级别',
            'level.in' => '消息级别只能是1、2或3',
        ];
    }
}